<?php

use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Storage;

Admin::routes();

Route::group([
    'prefix'     => config('admin.route.prefix'),
    'namespace'  => config('admin.route.namespace'),
    'middleware' => config('admin.route.middleware'),
], function (Router $router) {

    $router->get('/', 'HomeController@index')->name('admin.home');
    $router->resource('users', UserController::class);

    /**
     * 富文本文件上传
     */
    $router->post('/upload', function () {
        $urls = [];
        foreach (request()->file() as $file) {
            $path   = Storage::disk('admin')->putFile(
                'resource', $file
            );
            $urls[] = Storage::disk('admin')->url($path);
        }
        return [
            "errno" => 0,
            "data"  => $urls,
        ];
    });

});
